

export default class   RunJsr{
    run(name,obj,value,type){
        let comms=[]
        let root= qguan("root");
        let Dx=qguan("dx");
        let StrTo =qguan("strTo");
        let RunEntity=qguan("runEntity");
        let Phere=qguan("phere");
        let data=root.findData(name)
        data.then((data1)=>{
            let dx =new Dx();
            dx.loadData(data1);


            return new Promise(resolve => {
                resolve(dx)
            })

        }).then((dx)=>{  //预加载
            let rx= dx.searchFile(value);
            let phere=new Phere();
            let buff=rx.outData()
            phere.loadData(buff);

            let preloading=qguan("preloading");

             let tree=phere.toTree(1);
            let list=tree.children
                let ress=[];

            for (let i=0;i<list.length;i++){


                let comm=  preloading.run(list[i].name)
                ress.push(comm)

            }

            return new Promise(resolve => {
                Promise.all(ress).then(res=>{
                    resolve(dx);
                })

            })
        }).then((dx)=>{   //运行

            let rx=  dx.searchFile( obj);
            let phere=new Phere();
            phere.loadData(rx.outData());

            let tree=phere.toTree(1);
            let list=tree.children
            let comms=[];
            for (let i=0;i<list.length;i++){

                let comm=[];

                comm.push(list[i].type);
                comm.push(list[i].value);
                comm.push("");
                comm.push(list[i].name);
                comms.push(comm)
            }

            let runEnt=  new    RunEntity(comms)
            let Runcontext=qguan("runContext");
            let runContext=  Runcontext.getInstance();
            runContext.add(runEnt);
        })

    }


    //
}

